package component.firstPage;

import component.appointment.Appointment;
import component.appointment.AppointmentRecord;
import component.firstPage.Login.Login;
import static component.firstPage.register._register01.doRegister;
import component.medical.MedicalRecord;
import java.util.Scanner;

public class firstPage {
    public static void doFirstFunction() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("欢迎使用医疗系统");
        System.out.println("1. 登录");
        System.out.println("2. 注册");
        System.out.println("请选择(1-2)：");
        
        String choice = scanner.nextLine();
        switch (choice) {
            case "1":
                if (Login.doLogin()) {
                    System.out.println("登录成功");
                    showMainMenu();
                }
                break;
            case "2":
                doRegister();
                break;
            default:
                System.out.println("输入有误，请重新选择");
        }
    }

    private static void showMainMenu() {
        Scanner scanner = new Scanner(System.in);
        while (true) {
            System.out.println("\n=== 医疗系统主菜单 ===");
            System.out.println("1. 预约挂号");
            System.out.println("2. 查看我的预约");
            System.out.println("3. 查看就医记录");
            System.out.println("4. 退出系统");
            System.out.println("请选择(1-4)：");
            
            String choice = scanner.nextLine();
            switch (choice) {
                case "1":
                    Appointment.makeAppointment(getCurrentUserId());
                    break;
                case "2":
                    // 调用查看预约记录功能
                    AppointmentRecord AppointmentRecord = null;
                    AppointmentRecord.viewAppointments(getCurrentUserId());  // 需要从Login类获取当前用户ID
                    break;
                case "3":
                    MedicalRecord.viewMedicalRecords(getCurrentUserId());
                    break;
                case "4":
                    System.out.println("感谢使用，再见！");
                    return;
                default:
                    System.out.println("输入有误，请重新选择");
            }
        }

    }
    public static String getCurrentUserId(){
        return Login.getLoggedInUserId();
    }
}
